home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Business Shareware
/
Business Shareware.iso
/
start
/
gfxapps
/
hermite
/
motion.bas
next >
Wrap
BASIC Source File
|
1993-04-30
|
3KB
|
86 lines
DECLARE FUNCTION NextFile$ (n!, root$, ext$)
DECLARE FUNCTION CubicBlend! (t!, N1!, N2!, P1!, P2!)
DECLARE FUNCTION HermiteBlend! (t!, N1!, N2!, P1!, P2!)
DECLARE FUNCTION LinearBlend! (t!, N1!, N2!)
DECLARE FUNCTION QuadraticBlend! (t!, N1!, N2!, P1!)
'
' Demonstrates the use of Hermite blending function for camera control
' Notice the smooth speedup and slowdown.
' Dan Farmer April '93
'
CLS
OPEN "motion.bat" FOR OUTPUT AS #1
'OPEN "CONS:" FOR OUTPUT AS #1
float$="#####.#####"
' Name of animation files goes here:
root$ = "motion"
incfile$ = root$ + ".inc"
' Modify these to suit your system
render$ = "\povray\povray.exe \povray\povray.def -w160 -h100 -p -i" + root$ + ".pov -o"
dta$="call dta.bat " + root$
play$="play " + root$ + ".fli"
' Start and end values for camera location vector
xfrom=30 : xto=0
yfrom=30 : yto=1
zfrom=-50 : zto=-4
frames = 300
PRINT #1, "@echo off"
FOR frame = 1 TO frames
' Number the output file
tgafile$ = NextFile$(frame, root$, ".tga")
t = frame / frames
x = HermiteBlend(t, xfrom, xto, 0, 0) ' Last two params are controlling
y = HermiteBlend(t, yfrom, yto, 3, 4) ' values for the start and ending
z = HermiteBlend(t, zfrom, zto, 0, -30) ' slopes of the curve.
PRINT #1, "echo #declare XLoc = ";
PRINT #1, USING float$+" > " + incfile$; x
PRINT #1, "echo #declare YLoc = ";
PRINT #1, USING float$+" > " + incfile$; y
PRINT #1, "echo #declare ZLoc = ";
PRINT #1, USING float$+" > " + incfile$; z
PRINT #1, render$ + tgafile$
PRINT #1, "if errorlevel 1 exit" ' NOTE: This may fail w/ some versions
PRINT #1, ""
NEXT frame
PRINT #1, dta$
PRINT #1, play$"play motion.fli"
END
FUNCTION CubicBlend (t, N1, N2, P1, P2) STATIC
CubicBlend = (1 - t) ^ 3 * N1 + (t ^ 3) * N2 + 3 * t * ((1 - t) ^ 2) * P1 + 3 * (t ^ 2) * (1 - t) * P2
END FUNCTION
FUNCTION HermiteBlend (t, N1, N2, P1, P2)
HermiteBlend = (N1 * ((2! * t - 3!) * t ^ 2 + 1!) + N2 * (-2! * t + 3!) * t ^ 2 + P1 * ((t - 2!) * t + 1!) * t + P2 * (t - 1!) * t ^ 2)
END FUNCTION
FUNCTION LinearBlend (t, N1, N2) STATIC
LinearBlend = (1 - t) * N1 + t * N2
END FUNCTION
FUNCTION NextFile$ (n, root$, ext$) STATIC
STATIC i, pad$
i = 8 - LEN(root$)
pad$ = STRING$(8, "0")
NextFile$ = root$ + RIGHT$(pad$ + LTRIM$(STR$(n)), i) + ext$
END FUNCTION
FUNCTION QuadraticBlend (t, N1, N2, P1) STATIC
QuadraticBlend = (1 - t) ^ 2 * N1 + (t ^ 2) * N2 + 2 * t * (1 - t) * P1
END FUNCTION